cmake_minimum_required(VERSION 3.16)

set(test_libs
        PRIVATE GTest::gmock
        PRIVATE GTest::gtest_main
        PRIVATE spdlog::spdlog
        PRIVATE nlohmann_json::nlohmann_json
        PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
)
set(test_include ${CMAKE_SOURCE_DIR}/src)

function(add_unit_test name)
    foreach (item ${ARGN})
        list(APPEND source_list "${CMAKE_SOURCE_DIR}/${item}")
    endforeach ()

    add_executable(${name} ${source_list})
    target_link_libraries(${name} ${test_libs})
    target_include_directories(${name} PRIVATE ${test_include})
    add_test(NAME ${name} COMMAND ${name})
endfunction()

add_unit_test(scan_test tests/scan_test.cc src/scan.cc src/videoinfo.cc)